
<style scoped>
.handle-box {
    margin-bottom: 20px;
}
.box_iten{
    display: flex;
    flex-wrap: wrap;
}
</style>
<!-- tsx -->
<template>
    <div class="package">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-tickets"></i> 会 员 列 表 </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-input
                    clearable
                    v-model="query.name"
                    style="width: 200px; margin: 0 20px 0 0"
                    placeholder="商品名称"
                    class="handle-input mr10"
                ></el-input>
                <el-button type="primary" @click="getList">搜索</el-button>
            </div>
            <el-table :data="tableData" height="400" border class="table" ref="multipleTable" header-cell-class-name="table-header">
                <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
                <el-table-column prop="id" label="ID" show-overflow-tooltip  align="center"></el-table-column>
                <el-table-column prop="" label="缩略图" align="center">
                    <template slot-scope="scope">
                        <el-image style="width: 50px; height: 50px" :src="scope.row.thumbnail" :preview-src-list="[scope.row.thumbnail]">
                        </el-image>
                    </template>
                </el-table-column>
                <el-table-column prop="goodsName" label="商品名称"  align="center">
                    <!-- <template slot-scope="scope">
                    <span v-if="scope.row.fundTypeName == 10" >余额</span>
                    <span v-if="scope.row.fundTypeName == 20" >期权</span>
                    <span v-if="scope.row.fundTypeName == 30" >互助</span>
                  </template> -->
                </el-table-column>
                <el-table-column prop="standardName" label="规格名称"  align="center"></el-table-column>
                <el-table-column prop="count" label="数量"  align="center"></el-table-column>
                <el-table-column label="操作"  align="center" fixed="right">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="ru(scope.row.id)">入库</el-button>
                        <el-button size="mini" type="warning" @click="chu(scope.row.id)">出库</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    @size-change="sizeChange"
                    @current-change="pageChange"
                    :current-page="query.pageIndex"
                    :page-sizes="[20, 50, 100, 200]"
                    :page-size="query.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageTotal"
                >
                </el-pagination>
            </div>
        </div>
        <el-dialog title="出库" :visible.sync="chowChu" width="500px">
            <el-form ref="send" :model="chuFrom" label-width="100px">
                <!-- <el-form-item label="会员id:">
                    <el-input v-model="changePhone.id" disabled style="width: 300px"></el-input>
                </el-form-item> -->
                <el-form-item label="数量:">
                    <el-input v-model="chuFrom.count" style="width: 300px"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="chowChu = false">取 消</el-button>
                <el-button type="primary" @click="sureChuKu">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="入库" :visible.sync="chowRu" width="500px">
            <el-form ref="send" :model="ruFrom" label-width="100px">
                <!-- <el-form-item label="会员id:">
                    <el-input v-model="changePhone.id" disabled style="width: 300px"></el-input>
                </el-form-item> -->
                <el-form-item label="数量:">
                    <el-input v-model="ruFrom.count" style="width: 300px"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="chowRu = false">取 消</el-button>
                <el-button type="primary" @click="sureRuKu">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script >
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
import { PagingInventory,OutStocks,InStocks } from '@/api/stocks';
export default {
    // import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
        // 这里存放数据
        return {
            query: {
                pageIndex: 1,
                pageSize: 20,
            },
            pageTotal: 0,
            tableData: [],
            chuFrom:{},
            chowChu:false,
            ruFrom:{},
            chowRu:false,
            chuFrom:{}
        };
    },
    // 过滤器
    filters: {},
    // 监听属性 类似于data概念
    computed: {},
    // 监控data中的数据变化
    watch: {},
    // 方法集合
    methods: {
      chu(id){
        this.chuFrom.id = id
        this.chowChu =true
      },
      ru(id){
        this.ruFrom.id = id
        this.chowRu =true
      },
        pageChange(e) {
            this.query.pageIndex = e;
            this.getList();
        },
        getList() {
            PagingInventory(this.query).then((res) => {
                this.tableData = res.Data.list;
                this.pageTotal = res.Data.paging.totalItemCount;
            });
        },
        sizeChange(e) {
            this.query.pageSize = e;
            this.getList();
        },
        sureChuKu(){
          OutStocks(this.chuFrom).then(res => {
            this.$message.success('出库成功')
            this.chuFrom = {}
            this.chowChu =false
            this.getList()
          })
        },
        sureRuKu(){
          InStocks(this.ruFrom).then(res => {
            this.$message.success('入库成功')
            this.ruFrom = {}
            this.chowRu =false
            this.getList()
          })
        }
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created() {
        console.log(123);
        this.getList();
    },
    // 生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
    beforeCreate() {}, // 生命周期 - 创建之前
    beforeMount() {}, // 生命周期 - 挂载之前
    beforeUpdate() {}, // 生命周期 - 更新之前
    updated() {}, // 生命周期 - 更新之后
    beforeDestroy() {}, // 生命周期 - 销毁之前
    destroyed() {}, // 生命周期 - 销毁完成
    ctivated() {} // 如果页面有keep-alive缓存功能，这个函数会触发
};
</script>